-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Add compatibility checks for Schemas with default values #11434
API: Add compatibility checks for Schemas with default values #11434
Conversation
|
||
@ParameterizedTest | ||
@ValueSource(ints = {1, 2, 3}) | ||
public void testSupportedInitialDefault(int formatVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testSupportedWriterDefault?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testSupportedInitialDefault(int formatVersion) { | |
public void testSupportedWriterDefault(int formatVersion) { |
@ParameterizedTest | ||
@ValueSource(ints = {1, 2, 3}) | ||
public void testSupportedInitialDefault(int formatVersion) { | ||
// only the initial default is a forward-incompatible change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could make this self contained to the test by saying
Writer defaults are universally compatible
Or something?
Tests failing are because Metadata.json also has validations for this and this check is failing first |
problems.put( | ||
field.fieldId(), | ||
String.format( | ||
"Invalid type for %s: %s is not supported until v%s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing checks in TableMetadata look like
"Invalid type in v%s schema: struct.ts_nanos timestamptz_ns is not supported until v3"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, dm'd a patch for the one broken test (Expected error message has changed)
And one required change for the test name in this PR which is I believe misnamed
Updated. Thanks, @RussellSpitzer! |
Co-authored-by: Fokko Driesprong <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @RussellSpitzer
@@ -586,16 +587,37 @@ private List<NestedField> reassignIds(List<NestedField> columns, TypeUtil.GetID | |||
* @param formatVersion table format version | |||
*/ | |||
public static void checkCompatibility(Schema schema, int formatVersion) { | |||
// check the type in each field | |||
// accumulate errors as a treemap to keep them in a reasonable order | |||
Map<Integer, String> problems = Maps.newTreeMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional] if we are going for another revision as fieldId() is int
:
Map<Integer, String> problems = Maps.newTreeMap(); | |
Map<int, String> problems = Maps.newTreeMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primitives are not allowed as Map Keys :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or any type parameter I think ... I feel like this is a 1337code question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🚀 Let's get 1.7.0 out :)
Thanks everyone - @rdblue (for original fix), @Fokko , @anuragmantri , @kevinjqliu , @singhpk234 , @amogh-jahagirdar For reviews! |
…#11434) Co-authored-by: Russell Spitzer <[email protected]> Co-authored-by: Fokko Driesprong <[email protected]>
This updates
Schema.checkCompatibility
:initial-default
is not set for v1 and v2 tables, which would break forward compatibilitycheckCompatibility
inTestSchema
I think that this should get into 1.7.0 to avoid accidentally leaking initial defaults in v1 and v2 tables.